package com.hw.kafkaThread01;

import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.consumer.KafkaConsumer;

import java.time.Duration;
import java.util.Collections;
import java.util.Properties;

public class KafkaConsumerThread extends Thread {

    private KafkaConsumer kafkaConsumer;

    public KafkaConsumerThread(Properties config, String topic) {
        this.kafkaConsumer = new KafkaConsumer(config);
        this.kafkaConsumer.subscribe(Collections.singleton(topic));
    }

    @Override
    public void run() {
        while (true) {
            ConsumerRecords<String, String> records = kafkaConsumer.poll(Duration.ofSeconds(10));

        }
    }
}
